{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6d28b366",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.14156 <class 'float'>\n",
      "True <class 'bool'>\n",
      "80 <class 'int'>\n",
      "5 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "\n",
    "#数据类型\n",
    "#常用的数据类型\n",
    "#整数类型-int-98\n",
    "#浮点数类型-float-3.14159\n",
    "#布尔类型-bool-True，False\n",
    "#字符串类型-str-'人生苦短，我用python'\n",
    "a=3.14156\n",
    "b=True\n",
    "c=80\n",
    "str1='5'\n",
    "print(a,type(a))\n",
    "print(b,type(b))\n",
    "print(c,type(c))\n",
    "print(str1,type(str1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e66751e0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'> <class 'int'>\n",
      "我叫张三今年20岁\n"
     ]
    }
   ],
   "source": [
    "#数据类型转换  ——为了将不同数据连接在一起\n",
    "name='张三'\n",
    "age=20\n",
    "print(type(name),type(age)) #运行后说明name与age的数据类型不相同\n",
    "print('我叫'+name+'今年'+str(age)+'岁') #将int类型通过str（）函数转变成了str类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "26e00ae7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "————通过str（）函数转变成了str类型\n",
      "<class 'int'> <class 'float'> <class 'bool'>\n",
      "10 9.88 False\n",
      "<class 'str'> <class 'str'> <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "\n",
    "print('————通过str（）函数转变成了str类型')\n",
    "a=10\n",
    "b=9.88\n",
    "c=False\n",
    "print(type(a),type(b),type(c))     #发现是三种不同类型\n",
    "print(str(a),str(b),str(c))        #试着转为str类型\n",
    "print(type(str(a)),type(str(b)),type(str(c)))    #转换成功为str\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "41ad5b66",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "#列表\n",
    "a=[1,2,3]\n",
    "print(a,type(a))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "995bcabd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "vowels=['a','e','i','o','u']\n",
    "word=\"Milliways\"\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        print(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "6926aa01",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:beautiful\n",
      "e\n",
      "a\n",
      "u\n",
      "i\n"
     ]
    }
   ],
   "source": [
    "vowels=['a','e','i','o','u']\n",
    "word=input(\"Provide a word to search for vowels:\")\n",
    "found=[]\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        if letter not in found:\n",
    "            found.append(letter)\n",
    "for vowels in found:\n",
    "    print(vowels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "585c8908",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "和为 10\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "4步循环法\n",
    "1.初始化变量\n",
    "2.条件判断\n",
    "3.条件执行体（循环体）\n",
    "4.改变变量\n",
    "\"\"\"\n",
    "a=0  #初始化变量为0\n",
    "sum=0 \n",
    "while a<5:  #条件判断\n",
    "\tsum+=a  #总和，条件执行体(循环体)\n",
    "\ta+=1    #改变变量\n",
    "print(\"和为\",sum)   # a+=1相当于 a = a+1;sum+=a相当于sum=sum+a\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d291ed2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
